package starter

import (
	"fmt"
	"go-demo/router"
	"go-demo/starter/app"
)

type LoadApp interface {
	Load()
}

var loadList []LoadApp

func loading() {
	fmt.Println("项目开始加载启动项")
	// TODO 1.加载yaml配置
	loadList = append(loadList, new(app.ReadConfig)) //需要先加载,因为后续的应用需要用到配置信息才能启动

	loadList = append(loadList, new(app.MySQL))
	loadList = append(loadList, new(app.Redis))
	//loadList = append(loadList, new(app.Etcd))
	//loadList = append(loadList, new(app.ElasticSearch))

	loadList = append(loadList, new(router.Router)) //路由需要最后加载
}

func Start() {
	loading()
	for _, item := range loadList {
		item.Load()
	}
}
